/**
 * create by young (young2f@outlook.com) on 2023/5/21
 */
'use strict';

const _deviceMqtt = require('./core/interFace/mqtt/deviceReportMqtt');
const _deviceMgr = require('./core/deviceMgr')
const mqttMgr = require("./core/interFace/mqtt/routerMqttMgr");
module.exports = class {
    constructor(app) {
        this.app = app;
    }

    async restart() {
        /**
         * MQTT连接
         */
        if (!this.app.deviceMqtt) {
            this.app.deviceMqtt = new _deviceMqtt(this.app);
        }
        // mqtt连接并上报能力集
        const connectOk = await this.app.deviceMqtt.init();
        if (this.app.deviceMgr) {
            const res = await this.app.deviceMgr.destroy();
        }
        this.app.deviceMgr = new _deviceMgr(this.app);
        this.app.mqttMgr = new mqttMgr(this.app);
        this.app.mqttMgr.init();
    }
};
